package com.sl.hx.shop.ui.mine.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sl.hx.shop.R;
import com.sl.hx.shop.base.BaseActivity;
import com.sl.hx.shop.base.BasePresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class QuestionActivity extends BaseActivity {

    @BindView(R.id.question_into)
    ImageView questionInto;
    @BindView(R.id.content_coupon_nouser)
    TextView contentCouponNouser;
    @BindView(R.id.iv_get_coupon)
    ImageView ivGetCoupon;
    @BindView(R.id.rl_get_coupon)
    RelativeLayout rlGetCoupon;
    @BindView(R.id.content_get_coupon)
    TextView contentGetCoupon;
    @BindView(R.id.iv_login)
    ImageView ivLogin;
    @BindView(R.id.content_login)
    TextView contentLogin;
    @BindView(R.id.iv_order)
    ImageView ivOrder;
    @BindView(R.id.content_order)
    TextView contentOrder;
    @BindView(R.id.iv_pay)
    ImageView ivPay;
    @BindView(R.id.content_pay)
    TextView contentPay;
    @BindView(R.id.iv_rl_quality_goods)
    ImageView ivRlQualityGoods;
    @BindView(R.id.content_rl_quality_goods)
    TextView contentRlQualityGoods;
    @BindView(R.id.iv_search_goods)
    ImageView ivSearchGoods;
    @BindView(R.id.content_search_goods)
    TextView contentSearchGoods;

    private Boolean coupon = true;
    private Boolean getCoupon = true;
    private Boolean login = true;
    private Boolean order = true;
    private Boolean pay = true;
    private Boolean quality = true;
    private Boolean search = true;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_question;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }


    @OnClick({R.id.back, R.id.coupon_nouser,R.id.rl_get_coupon, R.id.rl_login, R.id.rl_order, R.id.rl_pay, R.id.rl_quality_goods, R.id.rl_search_goods})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            //优惠券无法使用
            case R.id.coupon_nouser:
                if (coupon) {
                    setBottomAndVisible(questionInto, contentCouponNouser);
                    coupon = false;
                } else {
                    setRightAndGone(questionInto, contentCouponNouser);
                    coupon = true;
                }
                break;
            //领取优惠券
            case R.id.rl_get_coupon:
                if (getCoupon) {
                    setBottomAndVisible(ivGetCoupon, contentGetCoupon);
                    getCoupon = false;
                } else {
                    setRightAndGone(ivGetCoupon, contentGetCoupon);
                    getCoupon = true;
                }
                break;
            //登录授权
            case R.id.rl_login:
                if (login) {
                    setBottomAndVisible(ivLogin, contentLogin);
                    login = false;
                } else {
                    setRightAndGone(ivLogin, contentLogin);
                    login = true;
                }
                break;
            //订单物流
            case R.id.rl_order:
                if (order) {
                    setBottomAndVisible(ivOrder, contentOrder);
                    order = false;
                } else {
                    setRightAndGone(ivOrder, contentOrder);
                    order = true;
                }
                break;
            //支付方式
            case R.id.rl_pay:
                if (pay) {
                    setBottomAndVisible(ivPay, contentPay);
                    pay = false;
                } else {
                    setRightAndGone(ivPay, contentPay);
                    pay = true;
                }
                break;
            //正品
            case R.id.rl_quality_goods:
                if (quality) {
                    setBottomAndVisible(ivRlQualityGoods, contentRlQualityGoods);
                    quality = false;
                } else {
                    setRightAndGone(ivRlQualityGoods, contentRlQualityGoods);
                    quality = true;
                }
                break;
            //找商品
            case R.id.rl_search_goods:
                if (search) {
                    setBottomAndVisible(ivSearchGoods, contentSearchGoods);
                    search = false;
                } else {
                    setRightAndGone(ivSearchGoods, contentSearchGoods);
                    search = true;
                }
                break;
        }
    }

    private void setRightAndGone(ImageView image, TextView textView) {
        image.setImageResource(R.drawable.question_into);
        textView.setVisibility(View.GONE);
    }

    private void setBottomAndVisible(ImageView image, TextView textView) {
        image.setImageResource(R.drawable.question_bottom);
        textView.setVisibility(View.VISIBLE);
    }


}
